package com.zsy.petshop_01.task;

import com.zsy.petshop_01.manager.PetManager;
import com.zsy.petshop_01.manager.SubscribeManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

@EnableScheduling // 启用定时任务
@Component
public class SubscribeTask {
    @Autowired
    SubscribeManager subscribeManager;
    @Autowired
    PetManager petManager;

    // 每天凌晨 0 点执行
    @Scheduled(cron = "0 0 0 * * ?")
    public void createSubscribeTask() {
        subscribeManager.createSenvenDays(LocalDate.now());
        petManager.createCheckSevenDays(LocalDate.now());
    }
}
